import 'package:flutter/material.dart';
import 'package:flutter_stort/model/banner_entity.dart';
import 'package:flutter_stort/widget/load_image.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class BannerView extends StatelessWidget {
  final List<BannerEntity> listBanner;
  final double width;
  final double height;
  final double padding;
  final double circular;
  BannerView({
    Key key,
    this.listBanner,
    this.width = double.infinity,
    this.height,
    this.padding = 0,
    this.circular = 0,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: height,
      width: width,
      padding: EdgeInsets.all(padding),
      child: Swiper(
        itemBuilder: (BuildContext context, int index) {
          return ClipRRect(
            borderRadius: BorderRadius.circular(circular),
            child: InkWell(
              onTap: () {
                print("    $index     ");
              },
              child: LoadImageView(
                imageUrl: listBanner[index].url,
                width: width,
                height: height,
                fit: BoxFit.cover,
              ),
            ),
          );
        },
        itemCount: listBanner.length,
        pagination: SwiperPagination(margin: EdgeInsets.all(8.0)),
        autoplay: true,
      ),
    );
  }
}
